package com.bawei.bydayzg_two.adapter

import android.graphics.Color
import android.widget.LinearLayout
import android.widget.TextView
import com.bawei.base.bean.IndexExplosiveMoney
import com.bawei.bydayzg_two.R
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder

class TypeAdapter:BaseQuickAdapter<IndexExplosiveMoney,BaseViewHolder>(R.layout.item_type) {
    var index = 4
    //
    override fun convert(holder: BaseViewHolder, item: IndexExplosiveMoney) {
        holder.setText(R.id.type_info,item.info)
        holder.setText(R.id.type_name,item.name)

        if (index == item.type.toInt()){
            holder.getView<TextView>(R.id.type_info).setTextColor(Color.RED)
            holder.getView<TextView>(R.id.type_name).setTextColor(Color.RED)
            holder.getView<LinearLayout>(R.id.type_ll).setBackgroundResource(R.drawable.bg_type)
        } else {
            holder.getView<TextView>(R.id.type_info).setTextColor(Color.BLACK)
            holder.getView<TextView>(R.id.type_name).setTextColor(Color.BLACK)
            holder.getView<LinearLayout>(R.id.type_ll).background = null
        }
    }
    //
    fun getIndex(position:Int){
        index = position
        notifyDataSetChanged()//刷新适配器，不然数据不会变化
    }
}